/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import java.util.Locale;
import javax.faces.context.FacesContext;

/**
 *
 * @author Turk
 */
public class LocaleCheck {
    private static Locale swedishLocale = new Locale("sv", "SE");

    /**
     * This function returns locale by checking the facescontext of the page
     * @param context
     * @return Locale
     */
    public Locale checkLocale(FacesContext context) {
        String path = null;
        path = context.getExternalContext().getRequestServletPath();
        if (path.indexOf("/sv_SE/") > 0) {
            Locale.setDefault(swedishLocale);
            return Locale.getDefault();
        } else {
            return Locale.ENGLISH;
        }
    }
}
